<?php
include_once "index.php";

//
//Check replacement for new line
//
if (isset($submit)) { // request from web form
   include_once "accesscontrol.php";
   define('BR', '<br />');	
} else { // request from outside like cronjobs
	 include_once "../conn.php";
	 define('BR', "\r\n");
	 header("Content-type: text/plain;");
}
echo BR;
echo BR;
echo BR;

//
// Function to find out 90 days for checking update jobseeker resume
//
function dateDiff($dformat, $endDate, $beginDate)
{
           $date_parts1=explode($dformat, $beginDate);
           $date_parts2=explode($dformat, $endDate);
           $start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
           $end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
           return $end_date - $start_date;
}

//
// Start send mail to jobseeker who didn't update resume >90 days
//
					$headers = "MIME-Version: 1.0\n"; 
					$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
					$headers .= "Content-Transfer-Encoding: 8bit\n"; 
					$headers .= "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>\n"; 
					$headers .= "X-Priority: 1\n"; 
					$headers .= "X-MSMail-Priority: High\n"; 
					$headers .= "X-Mailer: PHP/" . phpversion()."\n";
			    $today  = date("m/d/Y");
			    
			    $timestamp = time() - (90 * 24 * 60 * 60);
			    $datetime = date("Y-m-d h:i:s", $timestamp);


$sub = str_replace('{sitename}', $sitename, $_POST['subject']);
			
$q1 = "SELECT * FROM job_seeker_info " .
      "WHERE (`modifiedTime` IS NULL AND `createdTime` < '$datetime') " .
      "OR (`modifiedTime` IS NOT NULL AND `modifiedTime` < '$datetime' )";
$r1 = mysql_query($q1) or die(mysql_error());

while ($a1 = mysql_fetch_array($r1)){
			$msg = str_replace('{uname}', $a1['uname'], $_POST['message']);
	    $update = ($a1['modifiedTime']) ? $a1['modifiedTime'] : $a1['createdTime'];
			$date   = date("m/d/Y", strtotime($update));
			$diff   = dateDiff("/", $today, $date);
			
					$to = $a1['job_seeker_email'];
					$subject = $sub;
					$message_body = $msg; 
					$b = @mail($to, $subject, $message_body, $headers);
          $mesg = ($b) ? 'Reminder sent to  ' : 'Fail sending reminder to ';
				  echo $mesg.$a1['uname'].' ('.$to.') not up to date '.$diff.' days.'.BR;	

}


if (isset($submit)) { // from web form
	include_once('../footer.php');
}
	
exit;

?>


